﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using HR.Appointments.Service;

public partial class DisplayOrders : UserPage
{
    #region Events
    protected void Page_Load(object sender, EventArgs e)
    {
        _imgConfirm.Visible = IsLoggedIn;
        if (!string.IsNullOrEmpty(_txtPhoneNumber.Text))
        {
            ListOrders();
        }
    }

    protected void _btnViewList_Click(object sender, EventArgs e)
    {
        ListOrders();
    }
    #endregion

    #region Link Transfer
    protected void _ibmHomePage_Click(object sender, ImageClickEventArgs e)
	{
        if (!IsPostBack || (e.X != 0 && e.Y != 0))
        {
            Server.Transfer("~/Company.aspx",true);
        }
			
	}
	protected void _lbtnCompanyBooking_Click(object sender, EventArgs e)
	{
		Server.Transfer("~/Company.aspx",true);
	}
	protected void _lbtnHomePage_Click(object sender, EventArgs e)
	{
		Server.Transfer("~/Company.aspx", true);
    }
    #endregion

    #region Private List Methods
    private void ListOrders()
    {
        var list = Facade.Anonymous().GetPhone(_txtPhoneNumber.Text);
        if (list.Count != 0)
        {
            _dtgOrders.DataSource = list;
            _dtgOrders.DataBind();
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "ErrorAlert", "alert('Enginn pöntun fannst á þessu símanúmeri.');", true);
        }
    }
    #endregion
}
